<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-3.3.1.js"></script>
    <script>
        $(f);

        function f(){
            $("#c1").click(
                function(){
                   $("input:not(#c1)").each(function(index,ele){
                       // index 元素索引 // ele DOM元素
                       ele.checked = c1.checked;
                   });
                }
            );

            function allChecked(){
                var flag = true;

                $("input:not(#c1)").each(function(index,ele){// index 元素索引 // ele DOM元素
                    flag = flag && ele.checked;
                });

                return flag;
            }

            $("input:not(#c1)").click(function(){
                if(allChecked()){
                    c1.checked = "checked";
                }else{
                    c1.checked = false;
                }
            });
        }
    </script>
</head>
<body>







<input type="checkbox" id="c1" />
<input type="checkbox" />
<input type="checkbox" />
<input type="checkbox" />
<input type="checkbox" />

</body>
</html>